//
//  UIDevice+DDAdd.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/1/27.
//

import Foundation
import UIKit

public extension UIDevice {
    
    static func xq_width() -> CGFloat {
        return UIScreen.main.bounds.width
    }
    
    static func xq_height() -> CGFloat {
        return UIScreen.main.bounds.height
    }
    
    static func xq_safeTop() -> CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let window = windowScene.windows.first else { return 0 }
        return window.safeAreaInsets.top

    }
    
    static func xq_statusHeight() -> CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let statusBarManager = windowScene.statusBarManager else { return 0 }
        return statusBarManager.statusBarFrame.height
    }
    
    static func xq_navBarHeight() -> CGFloat {
        return 44
    }
    
    static func xq_topHeight() -> CGFloat {
        return UIDevice.xq_navBarHeight() + UIDevice.xq_statusHeight()
    }
    
    static func xq_bottomSafeMargin() -> CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let window = windowScene.windows.first else { return 0 }
        return window.safeAreaInsets.bottom
    }
    
}
